<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 亲友圈管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
    <link href="__STATIC__/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/css/new_file.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/information.css" />
    <style>
        /* 谷歌 */
        input::-webkit-outer-spin-button,
        input::-webkit-inner-spin-button {
            -webkit-appearance: none;
            appearance: none;
            margin: 0;
        }
        /* 火狐 */
        input{
            -moz-appearance:textfield;
        }
        .pan_x {
            cursor: pointer;
            margin-right: 5px;
        }
        .modal-dialog {
            position: absolute;
            top: 50%;
            left: 50%;
            z-index: 3;
            margin: auto;
            -webkit-transform: translate(-50%, -50%) !important;
            -moz-transform: translate(-50%, -50%) !important;
            -ms-transform: translate(-50%, -50%) !important;
            -o-transform: translate(-50%, -50%) !important;
            transform: translate(-50%, -50%) !important;
        }

    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>亲友圈管理</h5>
                </div>
                <div class="toogl_body">
                    <a href="Club.html"><button type="button" class="btn btn-w-m btn-bt btn-white">亲友圈管理</button></a>
                    <a href="Club_configure.html"><button type="button" class="btn btn-w-m btn-white btn-bt">蓝钻商城配置</button></a>
                    <a href="Club_goldcoin.html"><button type="button" class="btn btn-w-m btn-white btn-bt">黄钻商城配置</button></a>
                    <a href="Club_vipcard.html"><button type="button" class="btn btn-w-m btn-white btn-bt">会员卡商城配置</button></a>
                    <a href="Club_establish.html"><button type="button" class="btn btn-w-m btn-white btn-bt">创建亲友圈</button></a>

                    <!--<a href="Club_grant.html"><button type="button" class="btn btn-w-m btn-white btn-bt">金币发放</button></a>-->
                    <a href="Club_conf.html"><button type="button" class="btn btn-w-m btn-white btn-bt">亲友圈配置</button></a>
                    <a href="Club_from.html"><button type="button" class="btn btn-w-m btn-info btn-bt">房间配置</button></a>
                    <a href="room_management.html"><button type="button" class="btn btn-w-m btn-white btn-bt">房间管理</button></a>
                    <a href="join.html"><button type="button" class="btn btn-w-m btn-white btn-bt">亲友圈加入</button></a>
                    <div class="ibox-content ibox-jqGrid">
                        <div class="form-group mmp-gbl"><br/>
                            <label class="col-sm-2 control-dy">亲友圈ID：</label>
                            <div class="col-sm-8 form-time1">
                                <input type="number" placeholder="请输入亲友圈ID" class="form-control form-time-bk" id="room_id">
                            </div>
                            <button type="button" class="btn btn-info" id="find_bth">查询</button>
                            <button type="button" class="btn btn-danger" id="new_bth"  data-toggle="modal" data-target="">创建房间</button>
                        </div>
                        <div class="jqGrid_wrapper">
                            <table id="table_list_1"></table>
                            <div id="pager_list_1"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 修改  -->
<!-- <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div id="gray_Nr">
		<div class="col-sm-6" style="max-width: 550px;">
			<div class="ibox">
				<div class="ibox-title">
					<h5>提示消息</h5>
					<div class="ibox-tools" data-dismiss="modal">
						<a class="close-link">
							<i class="fa fa-times"></i>
						</a>
					</div>
				</div>
				<div class="panel-body">
					<div class="pan-div">
						<span class="pan_bt">选择游戏：</span>
						<select class="pan_input">
						    <option value ="volvo">选择游戏</option>
						</select>
					</div>
					<div class="pan-div">
						<span class="pan_bt">房间名称：</span>
						<input type="text" placeholder="请输入房间名称"  class="pan_input"/>
					</div>
					<div class="pan-div">
						<span class="pan_bt">玩家人数：</span>
						<span class="pan_x pan_rs">2人场</span>
						<span class="pan_x pan_rs">3人场</span>
						<span class="pan_x pan_rs">4人场</span>
					</div>
					<div class="pan-div">
						<span class="pan_bt">圈数局数：</span>
						<span class="pan_x pan_qs">1圈</span>
						<span class="pan_x pan_qs">2圈</span>
						<span class="pan_x pan_qs">4圈</span>
						<span class="pan_x pan_qs">4局</span>
						<span class="pan_x pan_qs">8局</span>
						<span class="pan_x pan_qs">16局</span>
					</div>
					<div class="pan-div">
						<span class="pan_bt">底分：</span>
						<span class="pan_x pan_df">底分1分</span>
						<span class="pan_x pan_df">底分2分</span>
						<span class="pan_x pan_df">底分5分</span>
					</div>
					<div class="pan-div">
						<span class="pan_bt">扣牌模式：</span>
						<span class="pan_x pan_kp">可碰杠</span>
						<span class="pan_x pan_kp">扣牌</span>
					</div>
					<div class="pan-div">
						<span class="pan_bt">荒庄处理：</span>
						<span class="pan_x pan_hz">荒庄见分下庄</span>
						<span class="pan_x pan_hz">荒庄荒杠</span>
					</div>
					<div class="pan-div room_cost">
						<span class="pan_bt">房费：</span>
						<span class="pan_x pan_jt">均摊</span>
					</div>
					<div class="pan-div">
						<span class="pan_bt">其他：</span>
						<span class="pan_x pan_qt">庄翻倍</span>
						<span class="pan_x pan_qt">无混吊</span>
						<span class="pan_x pan_qt">带金杠</span>
						<span class="pan_x pan_qt">带七对</span>
						<span class="pan_x pan_qt">七对没混</span>
					</div>
					<div class="pan-div">
						<span class="pan_bt">钻石消耗总数：</span>
						<input type="text" placeholder="请输入钻石消耗总数"  class="pan_input"/>
					</div>
				</div>
				<div class="ibox-butz">
					<input class="btn btn-w-m btn-info" type="button" value="确定">
					<input class="btn btn-w-m" type="button" data-dismiss="modal" value="取消">
				</div>
			</div>
		</div>
	</div>
</div> -->
<!--修改end-->
<!-- 添加   -->
<div id="myModal1" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div id="gray_Nr">
        <div class="col-sm-6" style="max-width: 550px;">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>提示消息</h5>
                    <div class="ibox-tools" data-dismiss="modal">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="panel-body">
                    <div class="pan-div">
                        <b class="pan_bt">选择游戏：</b>
                        <select class="pan_input" id="play_list">

                        </select>
                    </div>
                    <div class="pan-div">
                        <b class="pan_bt">*房间名称：</b>
                        <input type="text" placeholder="请输入房间名称" id="pho_tit_new"  class="pan_input" maxlength="5"/>
                    </div>
                    <div class="list no_cleran" style="display: none"></div>
                    <!-- <div class="pan-div">
                        <span class="pan_bt">玩家人数：</span>
                        <span class="pan_x pan_rs">2人场</span>
                        <span class="pan_x pan_rs">3人场</span>
                        <span class="pan_x pan_rs">4人场</span>
                    </div>
                    <div class="pan-div">
                        <span class="pan_bt">圈数局数：</span>
                        <span class="pan_x pan_qs">1圈</span>
                        <span class="pan_x pan_qs">2圈</span>
                        <span class="pan_x pan_qs">4圈</span>
                        <span class="pan_x pan_qs">4局</span>
                        <span class="pan_x pan_qs">8局</span>
                        <span class="pan_x pan_qs">16局</span>
                    </div>
                    <div class="pan-div">
                        <span class="pan_bt">底分：</span>
                        <span class="pan_x pan_df">底分1分</span>
                        <span class="pan_x pan_df">底分2分</span>
                        <span class="pan_x pan_df">底分5分</span>
                    </div>
                    <div class="pan-div">
                        <span class="pan_bt">扣牌模式：</span>
                        <span class="pan_x pan_kp">可碰杠</span>
                        <span class="pan_x pan_kp">扣牌</span>
                    </div>
                    <div class="pan-div">
                        <span class="pan_bt">荒庄处理：</span>
                        <span class="pan_x pan_hz">荒庄见分下庄</span>
                        <span class="pan_x pan_hz">荒庄荒杠</span>
                    </div>-->
                    <div class="pan-div room_cost">
                        <b class="pan_bt">*房费：</b>
                        <span class="pan_x pan_jt pho_dx_j">均摊</span>
                    </div>
                    <div class="pan-div pho_hod_x">
                        <b class="pan_bt">其他：</b>
                        <!-- <span class="pan_x pan_qt">庄翻倍</span>
                        <span class="pan_x pan_qt">无混吊</span>
                        <span class="pan_x pan_qt">带金杠</span>
                        <span class="pan_x pan_qt">带七对</span>
                        <span class="pan_x pan_qt">七对没混</span> -->
                    </div>
                    <div class="pan-div" id="dingwei_room" style="display: none;">
                        <b class="pan_bt">强制定位房：</b>
                        <span class="pan_x pan_qt" id="0">开启</span>
                        <!-- <span class="pan_x pan_qt pho_dx_j">关闭</span> -->
                    </div>
                    <div class="pan-div">
                        <b class="pan_bt">钻石消耗总数：</b>
                        <input type="text" placeholder="请输入钻石消耗总数" id="zuanshi" class="pan_input"/>
                    </div>
                </div>
                <div class="ibox-butz">
                    <input class="btn btn-w-m btn-info" id="new_change_btn" type="button" value="确定">
                    <input class="btn btn-w-m" type="button" data-dismiss="modal" value="取消">
                    <input class="btn btn-w-m btn-danger" id="del" type="button" data-toggle="modal" value="删除">
                </div>
            </div>
        </div>
    </div>
</div>
<!--添加end-->

<!--删除确认-->
<div id="myModal3_t" class="modal fade modal-dialog" tabindex="2" aria-hidden="true" >
    <div id="gray_Nr">
        <div class=" clu_Tc" style="width: 400px">

            <div class="ibox float-e-margins float-e-margins-2">
                <div class="ibox-title">
                    <h5>提示消息</h5>
                </div>
                <div class="wrapper wrapper-content animated fadeInRight">
                    <input type="hidden" id="guidHidden" />
                    <p class="clu_wre">删除俱乐部将无法恢复，是否继续删除？</p>
                </div>

                <div class="ibox-butz">
                    <input class="btn btn-w-m btn-info" type="button" id="button_ban_user" data-dismiss="modal" value="确定" onclick="del_room()">
                    <input class="btn btn-w-m  myModal_g" data-dismiss="modal" type="button" value="取消">
                </div>
            </div>
            <input type="hidden" id="guid">
        </div>
    </div>
</div>
<!--删除确认end-->
<!--手机导航-->
<div class="to-fdh" style="display: none;">
    <img class="to-imgd" src="__STATIC__/img/phonedh.jpg">
    <div class="mob-nrlb">
        <ul>
            <li>
                <a class="mob-nrdh">管理</a>
                <ul class="mob-nryc">
                    <li class="mob-nrdhli">
                        <a href="{:url('Player/gameplayer')}">玩家管理</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('system/notice')}">公告管理</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('email/mail')}">邮件管理</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('Club/club')}">亲友圈管理</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('Money/money')}">提现管理</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('Order/order')}">订单管理</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('Senior/binding')}">高级会长管理</a>
                    </li>
                </ul>
            </li>
            <li>
                <a class="mob-nrdh">数据</a>
                <ul class="mob-nryc">
                    <li class="mob-nrdhli">
                        <a href="{:url('data/datagk')}">概況</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('data/datawf')}">玩法</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('data/datalc')}">留存</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('data/datass')}">实时数据</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('data/dataczfx')}">充值分析</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('data/dataclub')}">亲友圈统计</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('data/president')}">高级会长</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('data/regionaldata')}">地区数据</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('data/Analysis')}">渠道分析</a>
                    </li>
                </ul>
            </li>
            <li>
                <a class="mob-nrdh mob-qbh">权限</a>
                <ul class="mob-nryc">
                    <li class="mob-nrdhli">
                        <a href="{:url('rule/rule_list')}">权限管理</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('rule/rule_group')}">用户组管理</a>
                    </li>
                    <li class="mob-nrdhli">
                        <a href="{:url('account/account_details')}">后台账号管理</a>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</div>
<div id="zkbg">
    <img src="__STATIC__/img/dp.gif">
</div>
<div class="vnl-zz" style="display:none">
    <div><img src="__STATIC__/img/bqhp.gif"></div>
</div>
<!--手机适配-->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/js/plugins/peity/jquery.peity.min.js"></script>
<script src="__STATIC__/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
<script src="__STATIC__/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>
<script src="__STATIC__/js/content.js?v=1.0.0"></script>
<script src="__STATIC__/js/plugins/laydate/laydate.js"></script>
<script src="__STATIC__/js/echarts.min.js"></script>
<script src="__STATIC__/js/echarts.common.min.js"></script>
<script>
    var room_id = "";//房间的ID
    var play_list = "";//房间玩法列表
    var room_length = "";//房间的数量

    //点击查询按钮
    $("#find_bth").on("click",function(){
        var room_id_input = $("#room_id").val();
        if(room_id_input == ""){
            alert("请输入亲友圈的ID")
        }else{
            room_id = room_id_input;//给全局变量赋值
            game_list();//获取所有的玩法列表
            room_rate();//获取房费模式
            get_club_type();//获取房间的类型，及有几个防作弊房间
            room_list();//获取对应的所有的房间列表

        }
    })
    //点击新增的按钮
    $("#new_bth").on("click",function(){
        var room_id_input = $("#room_id").val();
        $("#play_list").attr("disabled",false);//让玩法可以选择
        if(room_length>=8){ //判断数量大于了最高限制
            alert("新建房间已满！");
            return false;
        }
        if(room_id_input==""){
            alert("请输入亲友圈的ID,并且查询对应的房间。");
            return false;
        }
        $("#del").hide();//让删除按钮隐藏
        if(room_id_input==room_id){ //表示查询的和新建的房间id不一致
            $("#new_change_btn").unbind("click");
            $("#new_change_btn").on("click.new",function(){
                newHome();
            })
            $.ajax({
                type: "get",
                url: "__URL__/Game_rules",
                async: true,
                data:{
                    id:$("#play_list").val()
                },
                success: function (data) {
                    clean_new();
                    pull_data(data);
                    $("#myModal1").modal("show");
                }
            });
        }else{
            alert("请先查询对应亲友圈的房间");
        }
    })

    $("#dingwei_room span").click(function(){ //强制定位房间点击
        $(this).toggleClass("pho_dx_j");
    })

    $("#play_list").change(function(){
        Game_rules();
    })
    var d = "";
    var club_type = 1;//房间的类型
    var cheat = 0;//是否开启防作弊房间
    var cheat_num = "";//开启前防作弊房间的数量
    function get_club_type(){ //获取club_type
        $.ajax({
            type: "get",
            url: "__URL__/club_type",
            async: false,
            data:{
                club_id:room_id
            },
            success: function (data) {
                console.log(data);
                club_type = data.club_type;
                if(club_type==0){ //有房费，但是可以自己修改
                    $("#zuanshi").attr("disabled",false);
                    $(".room_cost").show();
                    d = "蓝钻消耗";
                }else{
                    $("#zuanshi").attr("disabled",true);//没有房费，但是不能自己修改
                    $(".room_cost").hide();
                    d = "黄钻消耗";
                }
                cheat = data.cheat;
                cheat_num = data.number;
                if(cheat==1&&cheat_num<2){ //cheat这个字段控制显示或者不显示
                    $("#dingwei_room").show();
                }else{
                    $("#dingwei_room").hide();
                }
            }
        });
    }
    function clean_new(){
        $("#pho_tit_new").val("");
        $("#zuanshi").val("");
        diamond_chang = "";
        $(".list").not(".no_cleran").remove();
        $(".ignore").remove();
        $(".pho_hod_x .pho_hom_dx").remove();
        $("#dingwei_room span").removeClass("pho_dx_j");
    }
    function Game_rules(){ //获取具体的玩法，应该是对应的新建
        $.ajax({
            type: "get",
            url: "__URL__/Game_rules",
            async: true,
            data:{
                id:$("#play_list").val()
            },
            success: function (data) {
                //console.log(data);
                clean_new();
                pull_data(data);
            }
        });
    }
    function game_list(){ //获取玩法列表
        $.ajax({
            type: "post",
            url: "{:url('club/game_list')}",
            data: {
                "clubId":room_id
            },
            dataType: "json",
            async: false,
            success: function(data) {
                var str = "";
                for(var i=0;i<data.length;i++){
                    str += "<option value="+data[i].id+">"+data[i].name+"</option>" ;
                }
                $("#play_list").html(str);
                play_list = data;
            },
            error: function(data) {

            }
        });
    }
    function room_rate(){ //获取房费模式
        $.ajax({
            type: "post",
            url: "{:url('club/room_rate')}",
            data: {
                "clubId":room_id
            },
            dataType: "json",
            async: false,
            success: function(data) {
                //console.log(data);
                $(".room_cost .pan_jt").attr({"data-name":data.id,"id":"0"}).text(data.name);
                payType = data.id;
            },
            error: function(data) {

            }
        });
    }
    function room_list(){ //获取房间列表
        $.ajax({
            type: "post",
            url: "{:url('club/room_list')}",
            data: {
                "club_id":room_id
            },
            dataType: "json",
            success: function(e) {
                //console.log(e);//原始数据
                room_length = e.length;
                for(var i = 0 ;i<e.length;i++){
                    if(e[i].room_rate==0){
                        e[i].room_rate = "均摊";
                    }else if(e[i].room_rate==1){
                        e[i].room_rate = "大赢家";
                    }else if(e[i].room_rate==2){
                        e[i].room_rate = "房主"
                    }
                    for (var j=0;j<play_list.length;j++){
                        if(e[i].room_type==play_list[j].id){
                            e[i].room_type = play_list[j].name;
                        }
                    }
                }
                mydata = e;
                //console.log(d);
                //console.log(mydata);
                $("#table_list_1").jqGrid('clearGridData');  //清空表格
                $("#table_list_1").jqGrid('setGridParam',{  // 重新加载数据
                    datatype:'local',
                    data : mydata,   //  newdata 是符合格式要求的需要重新加载的数据
                    page:1
                }).trigger("reloadGrid");
            },
            error: function(data) {

            }
        });
    }

    function pull_data(data,ischange){ //在页面上铺数据然后显示
        //console.log(ischange);
        var no_group_str = "";
        for(var i=0;i<data.group.length;i++){
            if(data.group[i].group!=undefined&&data.group[i].group!=null){ //下面的项有group
                if(data.group[i].required!=undefined&&data.group[i].required==true){ //如果有忽略的话
                    $(".list:last").after($('<div class="list pan-div pho_hod_'+(i+1)+'"></div>').html("<b class='pan_bt'>*"+data.group[i].name+":</b>"));
                }else{
                    $(".list:last").after($('<div class="ignore pan-div pho_hod_'+(i+1)+'"></div>').html("<b class='pan_bt'>"+data.group[i].name+":</b>"));//这个是只能选其中的一个，但是也能都不选
                }
                var str="";
                for(var j=0;j<data.group[i].group.length;j++){
                    var visibleBy = '';
                    if(data.group[i].group[j].hasOwnProperty("visibleSet")){ //如果有visible的话，给他加上visible的值， 作为class名。例如visible是2，这个元素的class名为visibleBy2，如果没有则统一为visible0
                        visibleBy = data.group[i].group[j].visibleSet;
                    }else {
                        visibleBy = ""
                    }
                    var default1 = "";
                    default1 = data.group[i].group[j].default==true?"pho_dx_j_def":"pho_dx_j_no";
                    if(data.group[i].group[j].hasOwnProperty("option")){ //为了得到是几人几局和几圈，但是不能直接检测set和round，所以检测的是option
                        var set = data.group[i].group[j].option.set ==undefined?"":data.group[i].group[j].option.set;
                        var round = data.group[i].group[j].option.round==undefined?"":data.group[i].group[j].option.round;
                        var playerSize = data.group[i].group[j].option.playerSize==undefined?"":data.group[i].group[j].option.playerSize;
                        str += '<span class="pho_hom_dx pan_x pho_d'+(i+1)+' '+'' +' '+ default1 +' playerSize_2" visibleset="'+visibleBy+'"   data-name-set="'+set+'" data-name-board="'+round+'" data-room-size="'+playerSize+'" id="'+data.group[i].group[j].id+'">'+data.group[i].group[j].name+'</span>';
                    }else{
                        str += '<span class="pho_hom_dx pan_x pho_d'+(i+1)+' '+'' +' '+ default1 +' playerSize_2" visibleset="'+visibleBy+'"  id="'+data.group[i].group[j].id+'">'+data.group[i].group[j].name+'</span>';
                    }
                }
                $('.pho_hod_'+(i+1)+'').append(str);
            }else{ //下面的没有group
                var default1 = "";
                default1 = data.group[i].default==true?"pho_dx_j_def":"pho_dx_j_no";
                var visibleBy = "";
                if(data.group[i].hasOwnProperty("visibleSet")){ //如果有visible的话，给他加上visible的值， 作为class名。例如visible是2，这个元素的class名为visibleBy2，如果没有则统一为visible0
                    visibleBy = data.group[i].visibleSet;
                }else {
                    visibleBy = ""
                }
                no_group_str +='<span class="pho_hom_dx pan_x pho_dx '+default1+' '+''+' " data-name-showN="0" visibleset="'+visibleBy+'" id="'+data.group[i].id+'">'+data.group[i].name+'</span>'
            }
        }
        $(".pho_hod_x").append(no_group_str);
        for(var i=0;i<$(".pho_hod_x .pho_dx").length;i++){
            everything_other($(".pho_hod_x .pho_dx").eq(i));
            // if($(".pho_hod_x .pho_dx").eq(i).attr("visibleset")!=""){
            //     $("#"+$(".pho_hod_x .pho_dx").eq(i).attr("visibleset")).hide();
                // var hide_span = $(".pho_hod_x #"+$(".pho_hod_x .pho_dx").eq(i).attr("visibleset"));
                // if(hide_span.attr("visibleset")){
                //     for(var j=0;j<hide_span.attr("visibleset").split(',').length;j++){
                //         $("#"+hide_span.attr("visibleset").split(',')[j]).hide();
                //     }
                // }
            //}
        }
        //让默认的选项选中
        if(ischange==undefined){ //如果是添加的话，让默认的选中，修改的话，先不管
            $(".pho_dx_j_def").addClass("pho_dx_j");
            for(var i=0;i<$(".pho_dx_j_def").length;i++){ 
                //if($(".pho_dx_j_def").eq(i).is(':visible')){ //让显示的选中的，进行everythings 
                    everything($(".pho_dx_j_def").eq(i));
                //}
                
            }
        }
    }

    function everything(this_,ischange){ //点击所有的list中添加一个事件，让其中的选中的visibleset都显示，让其兄弟元素，也就是没有选中的visibleset中的隐藏
        var siblings_span = this_.siblings("span");
        for(var i=0;i<siblings_span.length;i++){
            var visibleset = $(siblings_span[i]).attr("visibleset");
            if(visibleset.split(",").length==1){
                $("#"+visibleset).hide();
            }else{
                for(var j=0;j<visibleset.split(",").length;j++){
                    $("#"+visibleset.split(",")[j]).hide();
                }
            }
        }
        //console.log(this_);
        if(this_.attr("visibleset")&&this_.attr("visibleset").split(",").length==1){ //只有一个visibleset
            $("#"+this_.attr("visibleset")).show();
            //console.log("#"+this_.attr("visibleset"));
            if($("#"+this_.attr("visibleset")).hasClass("pho_dx_j_def")&&!ischange){
                everything($("#"+this_.attr("visibleset")));//递归,可能会出错
                $("#"+this_.attr("visibleset")).addClass("pho_dx_j");
                $("#"+this_.attr("visibleset")).siblings(".pho_dx_j_no").removeClass("pho_dx_j");
                if($("#"+this_.attr("visibleset")).attr("data-name-set")&&$("#"+this_.attr("visibleset")).hasClass("pho_dx_j")){
                    set = $("#"+this_.attr("visibleset")).attr("data-name-set");
                    boardType = "";
                }else if($("#"+this_.attr("visibleset")).attr("data-name-board")&&$("#"+this_.attr("visibleset")).hasClass("pho_dx_j")){
                    boardType = $("#"+this_.attr("visibleset")).attr("data-name-board");
                    set = "";
                }else if($("#"+this_.attr("visibleset")).attr("data-room-size")){
                    roomSize = $("#"+this_.attr("visibleset")).attr("data-room-size");
                }
            }
        }else if(this_.attr("visibleset")&&this_.attr("visibleset").split(",").length>1){ //需要循环
        //console.log("多个visibleset");
            for(var i=0;i<this_.attr("visibleset").split(",").length;i++){
                $("#"+this_.attr("visibleset").split(",")[i]).show();
                //console.log("#"+this_.attr("visibleset").split(",")[i]);
                if($("#"+this_.attr("visibleset").split(",")[i]).hasClass("pho_dx_j_def")&&!ischange){ //检测到有def,并且是新建的情况下
                    everything($("#"+this_.attr("visibleset").split(",")[i]));//递归,可能会出错
                    //console.log("进入这一个的id"+this_.attr("visibleset").split(",")[i]);
                    $("#"+this_.attr("visibleset").split(",")[i]).addClass("pho_dx_j");//给他加上变颜色
                    $("#"+this_.attr("visibleset").split(",")[i]).siblings(".pho_dx_j_no").removeClass("pho_dx_j");//让兄弟元素中的有no的去掉选中
                    if($("#"+this_.attr("visibleset").split(",")[i]).attr("data-name-set")){ //获取到圈数，局数的属性，并赋值
                        set = $("#"+this_.attr("visibleset").split(",")[i]).attr("data-name-set");
                        boardType = "";
                    }else if($("#"+this_.attr("visibleset").split(",")[i]).attr("data-name-board")){
                        boardType = $("#"+this_.attr("visibleset").split(",")[i]).attr("data-name-board");
                        set = "";
                    }else if($("#"+this_.attr("visibleset").split(",")[i]).attr("data-room-size")){
                        roomSize = $("#"+this_.attr("visibleset").split(",")[i]).attr("data-room-size");
                    }
                    //get_diamond_num();
                }
            }
        }

        if(this_.attr("data-name-set")){
            set = this_.attr("data-name-set");
            boardType = "";
            get_diamond_num();
        }else if(this_.attr("data-name-board")){
            boardType = this_.attr("data-name-board");
            set = "";
            get_diamond_num();
        }else if(this_.attr("data-room-size")){
            roomSize = this_.attr("data-room-size");
            get_diamond_num();
        }
    }
    $(".panel-body").delegate(".list span","click",function(){
        $(this).addClass("pho_dx_j").siblings().removeClass("pho_dx_j");//点击哪一个，让哪一个变红
        if($(this).attr("data-name-set")||$(this).attr("data-name-board")||$(this).attr("data-room-size")){
            diamond_chang = "";//把获取到的钻石消耗改成空，这样就能正确的赋值了。
        }
        everything($(this));
    })

    $(".panel-body").delegate(".ignore span","click",function(){
        $(this).toggleClass("pho_dx_j");
        $(this).siblings().removeClass("pho_dx_j");
        everything($(this));
    })

    $(".pho_hod_x").delegate(".pho_dx","click",function(){ //其中的选项，因为这里面都是多选的
        console.log("点击其他")
        $(this).toggleClass('pho_dx_j');
        everything_other($(this));
        
    })
    function everything_other(this_){ //这个是点击其他的时候的调用
        if(this_.attr("visibleset")!=""&&this_.is(":visible")&&this_.hasClass("pho_dx_j")){
            for(var i=0;i<this_.attr("visibleset").split(",").length;i++){
                $("#" + this_.attr("visibleset").split(",")[i]).show();
                everything_other($("#" + this_.attr("visibleset").split(",")[i]));
            }
        }else{
            if(this_.attr("visibleset")!=""){
                //$(".pho_hod_x #"+$(this).attr("visibleset")).hide();
                for(var i=0;i<this_.attr("visibleset").split(",").length;i++){
                    $("#" + this_.attr("visibleset").split(",")[i]).hide();
                    everything_other($("#" + this_.attr("visibleset").split(",")[i]));
                }
            }
        }
    }

    var diamond_num = "";
    var diamond_num_up = "";//钻石最大消耗
    var diamond_num_low = "";//钻石最小消耗
    var payType = "";//房费情况
    var roomSize="";//人数
    var set ="";//圈数
    var boardType="";//局数

    var del_room_id = "";
    function  get_diamond_num(){ //消耗钻石数量(通过ajax的调用)
    console.log("人数："+roomSize,"圈数："+set,"局数："+boardType);
        if(roomSize!=""&&(set!=""||boardType!="")){
            $.ajax({
                type: "get",
                //url: "__URL__/Play",
                url:"{:url('club/Play')}",
                async: true,
                data:{
                    people:roomSize,
                    ring:set,
                    bureau:boardType,
                    pid:$("#play_list").val(),
                    clubId:room_id
                },
                success: function (data) {
                    if(data){
                        $("#zuanshi").val(data);
                        diamond_num = data;
                        //console.log("最低消费："+diamond_num);
                        if(diamond_chang!=""){
                            $("#zuanshi").val(diamond_chang);
                        }
                    }
                }
            });
            $.ajax({
                type: "get",
                //url: "__URL__/Play_limit",
                url:"{:url('club/Play_limit')}",
                async: true,
                data:{
                    people:roomSize,
                    ring:set,
                    bureau:boardType,
                    pid:$("#play_list").val(),
                    clubId:room_id
                },
                success: function (data) {
                    if(data){
                        diamond_num_up = data.Upper_limit;
                        diamond_num_low = data.lower_limit;
                    }
                }
            });
        }
    }

    function newHome(thisid){ //新建、更改房间 向后台传输数据
        console.log(diamond_num_up+":"+diamond_num_low);
        var pho_tit = $('#pho_tit_new').val().length;
        var post_url =  "__URL__/room_options";
        if(thisid!=null&&thisid!=undefined){ //如果是修改的话，需要重新的更改url的值
            post_url = "__URL__/room_Modify"
        }
        for(var i=1;i<$("div.list").length;i++){ //循环监测有没有都添加的上数据
		
            if($("div.list").eq(i).find(".pho_dx_j").length!=0&&$("div.list").eq(i).find(".pho_dx_j").is(":visible")){  //有选中的
				
            }else{ //选中
				if($("div.list").eq(i).find("span").is(":visible")){
					alert("请选择"+$("div.list").eq(i).find(".pan_bt").text())
                	return false;
				}
            }
        }
        if ($('#pho_tit_new').val() == '') {
            alert("请填写房间名称");
        }else if (pho_tit >= 6) {
            alert("房间名称不得超过五个字");
        }else if(Number(diamond_num_up) < Number($("#zuanshi").val())){
            alert("钻石消耗数量范围："+diamond_num_low+"~"+diamond_num_up);
            return false;
        }else if(Number($("#zuanshi").val()) < Number(diamond_num_low)){ //检测钻石的消耗必须要一个范围内
            alert("钻石消耗数量范围："+diamond_num_low+"~"+diamond_num_up);
            return false;
        }else{
            var arr = []; //玩法转换成数组在传输
            for(var i=0;i<$(".pho_dx_j").length;i++){ //循环整个页面中的被选中的元素
                if($(".pho_dx_j").eq(i).attr("id")!=0){ //过滤id==0的，这样的是房费
                    if(arr.indexOf(Number($(".pho_dx_j").eq(i).attr("id")))==-1){ //过滤重复的？
                        if(!$(".pho_dx_j").eq(i).is(":hidden")){ //过滤隐藏的
                            arr.push(Number($(".pho_dx_j").eq(i).attr("id")));
                        }
                    }
                }
            }

            var consume = "";//钻石消耗
            if(club_type==0){
                consume = $("#zuanshi").val();
                if(consume==""||consume==undefined){
                    alert("请输入钻石");
                    return false;
                }
            }else{
                consume = $("#zuanshi").val();
                payType = -1;
            }
            var post_cheat = "";
            if($("#dingwei_room span").hasClass("pho_dx_j")){
                post_cheat = 1;
            }else{
                post_cheat = 0;
            }
            var post_data = JSON.stringify({
                "model_name":$('#pho_tit_new').val(), //房间名称
                "wanfa":arr, //玩法
                "fangfei":payType, //房费
                "consume":consume, //金币消耗
                "room_type":$("#play_list").val(), //玩法类型
                "cheat":post_cheat
            });
            ////console.log(post_data);
            $.ajax({
                type: "post",
                url: post_url,
                data: {
                    "arr":post_data,
                    "club_id":room_id,
                    "id":thisid
                },
                dataType: "json",
                success: function(e) {
                    alert(e.msg);
                    $("#myModal1").modal("hide");
                    //location.reload()
                    relad_roomlist();//重新拉取一边数据
                },
                error: function(e) {
                    //console.log(e);
                }
            });
            $("#myModal2").modal("hide");
        }
    };

    $(".room_cost span").on("click",function(){
        $(this).addClass("pho_dx_j");
    })
    var diamond_chang="";//更改按钮的时候，获取到的消耗的钻石数量
    function change(t){ //点击更改按钮
        //console.log(t);
        clean_new();
        $("#del").show();
        diamond_chang = $(t).attr("diamond");//获取到需要消耗的钻石数量
        var this_id = $(t).attr("id");
        del_room_id = this_id;
        $("#play_list").attr("disabled",false);
        $('#play_list').find("option").attr("selected",false);
        $(".room_cost span").removeClass("pho_dx_j");
        for(var i=0;i<play_list.length;i++){ //根据返回的游戏类型，选择对应的游戏id
            if($(t).attr("room_type")==play_list[i].name){
                $("#play_list").val(play_list[i].id);
                $("#play_list").attr("disabled",true);
                //console.log($("#play_list").val());
                $.ajax({ //获取游戏对应的配置项
                    type: "get",
                    url: "__URL__/Game_rules",
                    async: false,
                    data:{
                        id:$("#play_list").val()
                    },
                    success: function (data) {
                        pull_data(data,"change");
                    }
                });
            }
        }

        if($(t).attr("cheat")==1){ //根据数据中的chat是否等于1，来判断是否选中了强制定位
            $("#dingwei_room span").addClass("pho_dx_j");
            $("#dingwei_room").show();
        }else{
            $("#dingwei_room span").removeClass("pho_dx_j");
            if(cheat==1&&cheat_num<2){ //没有选中，但是需要显示
                $("#dingwei_room").show();
            }else{ //没有选中，不需要显示
                $("#dingwei_room").hide();
            }
        }

        $("#pho_tit_new").val($(t).attr("room_name"));//房间标题
        for(var i=0;i<$(".room_cost span").length;i++){ //获取房费的模式
            if($(".room_cost span").eq(i).text()==$(t).attr("room_rate")){
                $(".room_cost span").eq(i).addClass("pho_dx_j");
                payType = $(".room_cost span").eq(i).attr("data-name");
            }
        }
        var str = $(t).attr("options");
        options = eval(str)
        ////console.log(options);
        for(var i=0;i<options.length;i++){ //根据数组中的id的值，让该选中的选中
            var id = options[i];
            $("#myModal1 #"+id).addClass("pho_dx_j");
            everything($("#myModal1 #"+id),"ischange");
        }
        for(var i=0;i<$(".pho_hod_x .pho_dx_j").length;i++){ //让其他的选项中的选中的项能显示
            var this_ = $(".pho_hod_x .pho_dx_j").eq(i);
            if(this_.attr("visibleset")!=""&&this_.hasClass("pho_dx_j")){
                $(".pho_hod_x #"+this_.attr("visibleset")).show();
            }else{
                if(this_.attr("visibleset")!=""){
                    $(".pho_hod_x #"+this_.attr("visibleset")).hide();
                }
            }
        }

        $("#zuanshi").val($(t).attr("diamond"));//让钻石输入框显示正确的值
        $("#myModal1").modal("show");//让弹窗显示
        $("#new_change_btn").unbind("click");
        $("#new_change_btn").on("click.change",function(){ //给按钮绑定上修改时间
            newHome(this_id);
        })
    }


    $("#del").click(function(){
        ////console.log("打开确认删除对话框");
        $("#myModal1").modal("hide");
        $("#myModal3_t").modal("show");
    })
    function del_room(){
        $.ajax({
            type: "post",
            url: "__URL__/room_del",
            data: {
                'id':del_room_id,
            },
            dataType: "json",
            success: function(e) {
                alert(e.msg);
                //location.reload()
                relad_roomlist();//重新拉取数据
                $("#myModal3_t").modal("hide");
            },
            error: function(e) {
                //console.log(e);
            }
        });
    }
    function relad_roomlist(){ //重新拉取一边查询的数据
        game_list();//获取所有的玩法列表
        room_rate();//获取房费模式
        room_list();//获取对应的所有的房间列表
        get_club_type();//获取一遍强制定位房的数量
    }






    //导航显示展开
    $(".mob-nrdh").click(function(){
        $(this).next().toggle(".mob-nryc");
    });
    $(".to-imgd").click(function(){
        $(this).next().toggle(".mob-nrlb");
    });
    //手机适配end

    $(document).ready(function () {

        $.jgrid.defaults.styleUI = 'Bootstrap';
        // Examle data for jqGrid
        var mydata = [];
        // Configuration for jqGrid Example 1
        $("#table_list_1").jqGrid({
            data: mydata,
            datatype: "local",
            height: 350,
            autowidth: true,
            shrinkToFit: true,
            rowNum: 14,
            rowList: [10, 20, 30],
            colNames: ['游戏', '房间名称',"钻石消耗", '操作'],
            colModel: [
                {
                    name: 'room_type',
                    index: 'id',
                    width: 60,
                    sorttype: "data",
                    align:'center'
                },
                {
                    name: 'room_name',
                    index: 'invdate',
                    width: 90,

                    align:'center'
                },
                {
                    name:"diamond",
                    width:90,
                    align:"center"
                },
                {
                    name: 'isfinish',
                    index: 'isfinish',
                    width: 60,
                    formatter: function(cellvalue,options,rowObject) {
                        //console.log(rowObject);
                        var ags = '';
                        for(a in rowObject){
                            ags += a+"='"+""+rowObject[a]+"'";
                        }
                        return '<input type="button" value="修改"  data-toggle="modal" '+ags+' data-target="" onclick="change(this)" class="btn btn-info"/>';
                    },
                    align:'center'
                }
            ],
            pager: "#pager_list_1",
            viewrecords: true,
            caption: "当前房间列表",
            hidegrid: false
        });
        // Add responsive to jqGrid
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width();
            $('#table_list_1').setGridWidth(width);
            $('#table_list_2').setGridWidth(width);
        });
    });




    //手机适配
    $(function(){
        if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
            $("head").append("<link>");
            var css = $("head").children(":last");
            css.attr({
                rel:  "stylesheet",
                type: "text/css",
                href: "__STATIC__/css/phone_sp.css"
            });
            var mql = window.matchMedia("(orientation: portrait)");
            if(mql.matches) { //竖屏样式
                $(".vnl-zz").show();
                $(".to-fdh").hide();
            }else{
                $(".to-fdh").show();
                $("html").width("100%");
                $("body").width("100%");
            }
            mql.addListener(function(m) {
                if(m.matches) {
                    // 改变到直立方向
                    $(".vnl-zz").show();
                    $(".to-fdh").hide();
                }
                else {
                    $(".to-fdh").show();
                    $(".vnl-zz").hide();
                    $("html").width("100%");
                    $("body").width("100%");
                }
            });
        }
    });
</script>


</body>

</html>